<?php 
/**
 * eBay Label Printing Program Password handler
 * This is the password handler , it provide functions relate to password
 * @package  eBayLabelPrinter
 * @category Model
 * @author   Norman Dong <norman.dong@hotmail.com>
 * @version  Initial
 * @copyright LeadCasket.com
 * @link     www.leadcasket.com
 * @license  Commercial
 */
class Model_Handlers_Passwordhandler
{
	/**
	 * This is the generate password Function
	 * generate radom password for the customer
	 * @param bool $strongPassword  If Strong Password Needed
	 * @return string  6 to 8 length password
	 */	
	public function generatePassword($strongPassword = false){
		
		//generate a 8 digi Number password 
		
    	$chars="1234567890abcdef";
		if($strongPassword){
		$chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";	
			}
    	$minChars=6;
    	$maxChars=8;
     
    	//rest of script
    	$escapeCharPlus=0;
    	$repeat=mt_rand($minChars,$maxChars);
    	while ($escapeCharPlus<$repeat){
			
    		$randomWord.=$chars[mt_rand(1, strlen($chars)-1)];
    		$escapeCharPlus+=1;
    		}
    	//display random word
    		return $randomWord;		
		}
	/**
	 * This is the generate uniqueId Function
	 * generate radom uniqueId for the password hash
	 * @return string  18 chars unique id
	 */			
	public function generateUniqueId(){
		
		$maxLength = 18;
		return substr(md5(uniqid(rand(),true)),0,$maxLength);
		
		}
	/**
	 * This is the generate hashed password Function 
	 * Only hashed password stored in the database ,also using for check if the password match
	 * @return string  sha1 hashed password
	 */					
	public function generateHashPassword($userInputPassword,$userUniqueId){
		//the password stored in the database 
		return sha1($userUniqueId.$userInputPassword);
		} 	



	}
?>